#include <iostream>
#include <ctime>

#define N 5
#define M 2

using namespace std;

// FIMME: it is better to use `a[][]` do not use defined paramter in function definition
void cal(int a[M][N],int b[M]);

int main( )
{
    int a[M][N],m,i,j,b[M];
    int (*p)[N],*p1=b;
    p=a;

    srand((unsigned int)time(0));
    
    for(i=0;i<2;i++)
    {
        for(j=0;j<N;j++)
        {
            a[i][j]=rand()%20;
            cout<<a[i][j]<<"   ";
        }
        cout<<endl;
    }

    cal(p,p1);

    for(i=0;i<M;i++)
    {
        cout<<"  "<<b[i]<<"  ";
    }

    cin>>m;
    return 0;
}

void cal(int a[M][N],int b[M])
{
    int i,j,n=0;

    for(i=0;i<M;i++)
    {
        for(j=0;j<N;j++)
        {
            n=n+a[i][j];
        }
        *b=n;
        b++;
        n=0;
    }
}


